package com.tentact.dao;

import com.tentact.vo.Employee;
import com.tentact.vo.MeetingRoom;

import java.sql.SQLException;
import java.util.List;

public class Chf_mRoomDao {
    //查找meetingroom所有数据
    public List<MeetingRoom> selectMeeting(){
        String sql = "select * from meetingroom";
        Object[] para = null;
        RowMapper<MeetingRoom> rm = rs -> {
            MeetingRoom mr=new MeetingRoom();
            try {
                mr.setRoomid(rs.getInt("RoomId"));
                mr.setRoomcode(rs.getString("RoomCode"));
                mr.setRoomname(rs.getString("RoomName"));
                mr.setRoomcapacity(rs.getInt("RoomCapacity"));
                mr.setRoomstatus(rs.getInt("RoomStatus"));
                mr.setDescription(rs.getString("Description"));
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
            return  mr;
        };
        return  Dbutil.executeQuery(sql,para,rm);
    }
    //通过人数查找
    public List<MeetingRoom> selectMeetingByCapacity(int capacity){
        String sql = "SELECT * from meetingroom  m WHERE m.RoomCapacity < ?";
        Object[] para = {capacity};
        RowMapper<MeetingRoom> rm = rs -> {
            MeetingRoom mr=new MeetingRoom();
            try {
                mr.setRoomid(rs.getInt("RoomId"));
                mr.setRoomcode(rs.getString("RoomCode"));
                mr.setRoomname(rs.getString("RoomName"));
                mr.setRoomcapacity(rs.getInt("RoomCapacity"));
                mr.setRoomstatus(rs.getInt("RoomStatus"));
                mr.setDescription(rs.getString("Description"));
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
            return  mr;
        };
        return  Dbutil.executeQuery(sql,para,rm);
    }



}
